<?php

namespace Pinenut\Form;

abstract class Validator extends \Action
{
	protected static $layout = null;

	protected static $defaultViews = [];

	protected $defaultErrorMessage;

	abstract protected function isValid($value, $params);

	protected function runStage()
	{
		$this->response->content = $this->run();
	}

	public function run()
	{
		if ($this->isValid($this->request->value, $this->request->params())) {
            return;
        } else {
			return $this->request->errorMessage ?$this->request->errorMessage: $this->defaultErrorMessage;
		}
	}
}